package com.xuyuan.ai.image;


import org.springframework.ai.image.ImageModel;
import org.springframework.ai.image.ImagePrompt;
import org.springframework.ai.image.ImageResponse;
import org.springframework.ai.qianfan.QianFanImageOptions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xuyuan
 * @desc Image Model - 使用的是QianFan提供的ERNIE iRAG。统一了与专用于图像生成的 AI 模型的通信。
 */
@RestController
public class ImageController {

    @Autowired
    @Qualifier("qianFanImageModel")
    ImageModel qianFanImageModel;

    /**
     * TODO irag-1.0 暂时不可用，后续开放再测试图片生成
     */
    @GetMapping("/ai/image")
    public String image() {
        ImageResponse response = qianFanImageModel.call(new ImagePrompt("A light cream colored mini golden doodle", QianFanImageOptions.builder().N(4).height(1024).width(1024).build()));
        return response.getResults().get(0).getOutput().getUrl();
    }
}